<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2023-02-04 13:46:17
 * @Last Modified time: 2023-02-04 14:51:25
 */
namespace app\api\controller\store;	
use think\facade\App;
use app\common\services\store\GoodsCollectionService;

/**
 * Class GoodsCollection
 */
class GoodsCollection extends \app\api\controller\Base
{ 	
    /**
     * GoodsCollectionService constructor.
     * @param App $app
     */
    public function __construct(App $app,GoodsCollectionService $service)
    {
        parent::__construct($app);
        $this->service = $service;
    }

    /**
     * 商品收藏
     * @method(POST)
     */
    public function set(){
        $goodsId = $this->request->param('id');
        if(!$this->service->set($goodsId,$this->uid)){
            $this->error($this->service->getError()?:'处理失败',$this->service->action);
        }
        $this->success('处理成功',$this->service->action);
    }

    /**
     * 获取商品收藏列表
     * @method(GET)
     */
    public function list(){
        $list = $this->service->getGoodsCollectionList($this->uid);
        $this->success('获取成功',$list);
    }


}